remove unused adjustedBranchRefresh associated file parameter
authorJoey Hess <joeyh@joeyh.name>
Fri, 21 Feb 2025 18:51:02 +0000 (14:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 21 Feb 2025 18:51:02 +0000 (14:51 -0400)
19 files changed:
Annex/AdjustedBranch.hs
Annex/Content.hs
Annex/Import.hs
Annex/Ingest.hs
Annex/Transfer.hs
CmdLine/GitRemoteAnnex.hs
Command/Multicast.hs
Command/ReKey.hs
Command/RecvKey.hs
Command/Reinject.hs
Command/SetKey.hs
Command/TestRemote.hs
Command/TransferKey.hs
Command/TransferKeys.hs
Command/Transferrer.hs
P2P/Annex.hs
Remote/Git.hs
Upgrade/V0.hs
Upgrade/V1.hs

index 99cd40e835b93d052f38e984f8ba97e4c2aa9671..95bd8cfc3424cb27dba56774c8a4434692ea8d5e 100644 (file)
@@ -308,16 +308,12 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                -- adjustment is stable.
                return True
 
-{- Passed an action that, if it succeeds may get or drop the Key associated
- - with the file. When the adjusted branch needs to be refreshed to reflect
+{- Passed an action that, if it succeeds may get or drop a key.
+ - When the adjusted branch needs to be refreshed to reflect
  - those changes, it's handled here.
- -
- - Note that the AssociatedFile must be verified by this to point to the
- - Key. In some cases, the value was provided by the user and might not
- - really be an associated file.
  -}
-adjustedBranchRefresh :: AssociatedFile -> Annex a -> Annex a
-adjustedBranchRefresh _af a = do
+adjustedBranchRefresh :: Annex a -> Annex a
+adjustedBranchRefresh a = do
        r <- a
        go
        return r
index c4a0f8490c0b66895477b9ee944f4aa53ac36c09..f01432669ebb02be0dcd3d74ee3d57ebe2f1b1dd 100644 (file)
@@ -376,16 +376,16 @@ lockContentUsing contentlocker key fallback a = withContentLockFile key $ \mlock
 {- Runs an action, passing it the temp file to get,
  - and if the action succeeds, verifies the file matches
  - the key and moves the file into the annex as a key's content. -}
-getViaTmp :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> AssociatedFile -> Maybe FileSize -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
-getViaTmp rsp v key af sz action =
+getViaTmp :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> Maybe FileSize -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
+getViaTmp rsp v key sz action =
        checkDiskSpaceToGet key sz False $
-               getViaTmpFromDisk rsp v key af action
+               getViaTmpFromDisk rsp v key action
 
 {- Like getViaTmp, but does not check that there is enough disk space
  - for the incoming key. For use when the key content is already on disk
  - and not being copied into place. -}
-getViaTmpFromDisk :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> AssociatedFile -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
-getViaTmpFromDisk rsp v key af action = checkallowed $ do
+getViaTmpFromDisk :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
+getViaTmpFromDisk rsp v key action = checkallowed $ do
        tmpfile <- prepTmp key
        resuming <- liftIO $ doesPathExist tmpfile
        (ok, verification) <- action tmpfile
@@ -400,7 +400,7 @@ getViaTmpFromDisk rsp v key af action = checkallowed $ do
                else verification
        if ok
                then ifM (verifyKeyContentPostRetrieval rsp v verification' key tmpfile)
-                       ( pruneTmpWorkDirBefore tmpfile (moveAnnex key af)
+                       ( pruneTmpWorkDirBefore tmpfile (moveAnnex key)
                        , do
                                verificationOfContentFailed tmpfile
                                return False
@@ -507,8 +507,8 @@ withTmp key action = do
  - accepted into the repository. Will display a warning message in this
  - case. May also throw exceptions in some cases.
  -}
-moveAnnex :: Key -> AssociatedFile -> OsPath -> Annex Bool
-moveAnnex key af src = ifM (checkSecureHashes' key)
+moveAnnex :: Key -> OsPath -> Annex Bool
+moveAnnex key src = ifM (checkSecureHashes' key)
        ( do
 #ifdef mingw32_HOST_OS
                {- Windows prevents deletion of files that are not
@@ -523,7 +523,7 @@ moveAnnex key af src = ifM (checkSecureHashes' key)
   where
        storeobject dest = ifM (liftIO $ doesPathExist dest)
                ( alreadyhave
-               , adjustedBranchRefresh af $ modifyContentDir dest $ do
+               , adjustedBranchRefresh $ modifyContentDir dest $ do
                        liftIO $ moveFile src dest
                        -- Freeze the object file now that it is in place.
                        -- Waiting until now to freeze it allows for freeze
@@ -776,7 +776,7 @@ removeAnnex (ContentRemovalLock key) = withObjectLoc key $ \file ->
        -- it's unmodified.
        resetpointer file = unlessM (liftIO $ isSymbolicLink <$> R.getSymbolicLinkStatus (fromOsPath file)) $
                ifM (isUnmodified key file)
-                       ( adjustedBranchRefresh (AssociatedFile (Just file)) $
+                       ( adjustedBranchRefresh 
                                depopulatePointerFile key file
                        -- Modified file, so leave it alone.
                        -- If it was a hard link to the annex object,
index b351504ace4be0f8a14bd2d7d0772a3fb5765d7b..2e86df920d5d3611e656f7fb90a8692eb37b446a 100644 (file)
@@ -863,7 +863,7 @@ importKeys remote importtreeconfig importcontent thirdpartypopulated importablec
                                        ia loc [cid] tmpfile
                                        (Left k)
                                        (combineMeterUpdate p' p)
-                               ok <- moveAnnex k af tmpfile
+                               ok <- moveAnnex k tmpfile
                                when ok $
                                        logStatus NoLiveUpdate k InfoPresent
                                return (Just (k, ok))
@@ -906,7 +906,7 @@ importKeys remote importtreeconfig importcontent thirdpartypopulated importablec
                                p
                        case keyGitSha k of
                                Nothing -> do
-                                       ok <- moveAnnex k af tmpfile
+                                       ok <- moveAnnex k tmpfile
                                        when ok $ do
                                                recordcidkey cidmap cid k
                                                logStatus NoLiveUpdate k InfoPresent
index 695a0cb0631804f539d28130d7419dacd5b99363..07b5dad282acdcfbb871344ab27071c23ed6d947 100644 (file)
@@ -198,17 +198,11 @@ ingest' preferredbackend meterupdate (Just (LockedDown cfg source)) mk restage =
                | otherwise = gounlocked key mcache
 
        golocked key mcache =
-               tryNonAsync (moveAnnex key naf (contentLocation source)) >>= \case
+               tryNonAsync (moveAnnex key (contentLocation source)) >>= \case
                        Right True -> success key mcache
                        Right False -> giveup "failed to add content to annex"
                        Left e -> restoreFile (keyFilename source) key e
 
-       -- moveAnnex uses the AssociatedFile provided to it to unlock
-       -- locked files when getting a file in an adjusted branch.
-       -- That case does not apply here, where we're adding an unlocked
-       -- file, so provide it nothing.
-       naf = AssociatedFile Nothing
-
        gounlocked key (Just cache) = do
                -- Remove temp directory hard link first because
                -- linkToAnnex falls back to copying if a file
@@ -377,7 +371,7 @@ addAnnexedFile matcher file key mtmp = ifM (addUnlocked matcher mi (isJust mtmp)
                stagePointerFile file mode =<< hashPointerFile key
                Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file)
                case mtmp of
-                       Just tmp -> ifM (moveAnnex key af tmp)
+                       Just tmp -> ifM (moveAnnex key tmp)
                                ( linkunlocked mode >> return True
                                , writepointer mode >> return False
                                )
@@ -388,11 +382,10 @@ addAnnexedFile matcher file key mtmp = ifM (addUnlocked matcher mi (isJust mtmp)
        , do
                addSymlink file key Nothing
                case mtmp of
-                       Just tmp -> moveAnnex key af tmp
+                       Just tmp -> moveAnnex key tmp
                        Nothing -> return True
        )
   where
-       af = AssociatedFile (Just file)
        mi = case mtmp of
                Just tmp -> MatchingFile $ FileInfo
                        { contentFile = tmp
index 45969003ae86a64bf195af9b984d88604a086f27..7ec629e442b764ef844d82f49919ef8486ffc09a 100644 (file)
@@ -78,7 +78,7 @@ download r key f d witness =
                Just StallDetectionDisabled -> go Nothing
                Just sd -> runTransferrer sd r key f d Download witness
   where
-       go sd = getViaTmp (Remote.retrievalSecurityPolicy r) vc key Nothing $ \dest ->
+       go sd = getViaTmp (Remote.retrievalSecurityPolicy r) vc key Nothing $ \dest ->
                download' (Remote.uuid r) key f sd d (go' dest) witness
        go' dest p = verifiedAction $
                Remote.retrieveKeyFile r key f dest p vc
index 79d6befd5b33d997deab16ae242a61e8baac7313..beacd137a36c28d6fb3fa8fcd753c6d5cd9d6545 100644 (file)
@@ -927,7 +927,7 @@ downloadGitBundle rmt k = getKeyExportLocations rmt k >>= \case
 
        getexport loc = catchNonAsync (getexport' loc) (const (pure False))
        getexport' loc =
-               getViaTmp rsp vc k (AssociatedFile Nothing) Nothing $ \tmp -> do
+               getViaTmp rsp vc k Nothing $ \tmp -> do
                        v <- Remote.retrieveExport (Remote.exportActions rmt)
                                k loc tmp nullMeterUpdate
                        return (True, v)
@@ -986,7 +986,7 @@ generateGitBundle rmt bs manifest =
                        tmp nullMeterUpdate
                if (bundlekey `notElem` inManifest manifest)
                        then do
-                               unlessM (moveAnnex bundlekey (AssociatedFile Nothing) tmp) $
+                               unlessM (moveAnnex bundlekey tmp) $
                                        giveup "Unable to push"
                                return (bundlekey, uploadaction bundlekey)
                        else return (bundlekey, noop)
index 280f862fe41632283cdff994c0f4deb13cd38709..f29db57e476df64387b6812fcf930b13b4d60480 100644 (file)
@@ -213,7 +213,7 @@ storeReceived f = do
                        warning $ "Received a file " <> QuotedPath f <> " that is not a git-annex key. Deleting this file."
                        liftIO $ removeWhenExistsWith removeFile f
                Just k -> void $ logStatusAfter NoLiveUpdate k $
-                       getViaTmpFromDisk RetrievalVerifiableKeysSecure AlwaysVerify k (AssociatedFile Nothing) $ \dest -> unVerified $
+                       getViaTmpFromDisk RetrievalVerifiableKeysSecure AlwaysVerify k $ \dest -> unVerified $
                                liftIO $ catchBoolIO $ do
                                        renameFile f dest
                                        return True
index 3f02f2ab60ed0f367e2e28cafcafd23943f53c28..8688dff25c2260a6f49cf8f07e89d3285205d601 100644 (file)
@@ -128,7 +128,7 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
  - and vulnerable to corruption. -}
 linkKey' :: VerifyConfig -> Key -> Key -> Annex Bool
 linkKey' v oldkey newkey =
-       getViaTmpFromDisk RetrievalAllKeysSecure v newkey (AssociatedFile Nothing) $ \tmp -> unVerified $ do
+       getViaTmpFromDisk RetrievalAllKeysSecure v newkey $ \tmp -> unVerified $ do
                oldobj <- calcRepo (gitAnnexLocation oldkey)
                isJust <$> linkOrCopy' (return True) newkey oldobj tmp Nothing
 
index b1cd9262365cf9d86432b85ed4c3d512c68b348b..c3f0eb32896773f7a0f208c69e6f8c7a72e8badf 100644 (file)
@@ -28,7 +28,7 @@ start :: (SeekInput, Key) -> CommandStart
 start (_, key) = fieldTransfer Download key $ \_p -> do
        -- This matches the retrievalSecurityPolicy of Remote.Git
        let rsp = RetrievalAllKeysSecure
-       ifM (getViaTmp rsp DefaultVerify key (AssociatedFile Nothing) Nothing go)
+       ifM (getViaTmp rsp DefaultVerify key Nothing go)
                ( do
                        logStatus NoLiveUpdate key InfoPresent
                        _ <- quiesce True
index 7ea45623fb6334ef18b65b94635007a50eea8b09..0e5d2651d31b12865ddae2c902e1637062425baf 100644 (file)
@@ -129,7 +129,7 @@ perform src key = do
                )
   where
        move = checkDiskSpaceToGet key Nothing False $
-               moveAnnex key (AssociatedFile Nothing) src
+               moveAnnex key src
 
 cleanup :: Key -> CommandCleanup
 cleanup key = do
index b7db0200df8ac6e68d7513cfb6121feace7a1de6..0026f82295604718a426a9e6a8bf7ced0512fa02 100644 (file)
@@ -36,7 +36,7 @@ perform file key = do
        -- the file might be on a different filesystem, so moveFile is used
        -- rather than simply calling moveAnnex; disk space is also
        -- checked this way.
-       ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key (AssociatedFile Nothing) Nothing $ \dest -> unVerified $
+       ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key Nothing $ \dest -> unVerified $
                if dest /= file
                        then liftIO $ catchBoolIO $ do
                                moveFile file dest
index b35ee6ecb240882b36c924f1d60101834c81438f..3bc161d3fe864b9a54c0f0568201ab438a01993f 100644 (file)
@@ -301,7 +301,7 @@ test runannex mkr mkk =
                        Just verifier -> do
                                loc <- Annex.calcRepo (gitAnnexLocation k)
                                verifier k loc
-       get r k = logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest ->
+       get r k = logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest ->
                tryNonAsync (Remote.retrieveKeyFile r k (AssociatedFile Nothing) dest nullMeterUpdate (RemoteVerify r)) >>= \case
                        Right v -> return (True, v)
                        Left _ -> return (False, UnVerified)
@@ -375,13 +375,13 @@ testUnavailable runannex mkr mkk =
        , check (`notElem` [Right True, Right False]) "checkPresent" $ \r k ->
                Remote.checkPresent r k
        , check (== Right False) "retrieveKeyFile" $ \r k ->
-               logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest ->
+               logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest ->
                        tryNonAsync (Remote.retrieveKeyFile r k (AssociatedFile Nothing) dest nullMeterUpdate (RemoteVerify r)) >>= \case
                                Right v -> return (True, v)
                                Left _ -> return (False, UnVerified)
        , check (== Right False) "retrieveKeyFileCheap" $ \r k -> case Remote.retrieveKeyFileCheap r of
                Nothing -> return False
-               Just a -> logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest -> 
+               Just a -> logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest -> 
                        unVerified $ isRight
                                <$> tryNonAsync (a k (AssociatedFile Nothing) dest)
        ]
@@ -443,7 +443,7 @@ randKey sz = withTmpFile (literalOsPath "randkey") $ \f h -> do
        k <- case Types.Backend.genKey Backend.Hash.testKeyBackend of
                Just a -> a ks nullMeterUpdate
                Nothing -> giveup "failed to generate random key (backend problem)"
-       _ <- moveAnnex k (AssociatedFile Nothing) f
+       _ <- moveAnnex k f
        return k
 
 getReadonlyKey :: Remote -> OsPath -> Annex Key
index 9732e7d65657a29c6ed5794be2866b267b1bf632..242508230568ebb1737620ed61c7e18ee27858cf 100644 (file)
@@ -63,7 +63,7 @@ toPerform key af remote = go Upload af $
 fromPerform :: Key -> AssociatedFile -> Remote -> CommandPerform
 fromPerform key af remote = go Upload af $
        download' (uuid remote) key af Nothing stdRetry $ \p ->
-               logStatusAfter NoLiveUpdate key $ getViaTmp (retrievalSecurityPolicy remote) vc key af Nothing $ \t ->
+               logStatusAfter NoLiveUpdate key $ getViaTmp (retrievalSecurityPolicy remote) vc key Nothing $ \t ->
                        tryNonAsync (Remote.retrieveKeyFile remote key af t p vc) >>= \case
                                Right v -> return (True, v)     
                                Left e -> do
index f06a687c713c5ee64b0a4958daed430d00a8b4be..07a0051ed07a4ee343b9f58f01e779c37a4ef04b 100644 (file)
@@ -50,7 +50,7 @@ start = do
                                                return True
                | otherwise = notifyTransfer direction af $
                        download' (Remote.uuid remote) key af Nothing stdRetry $ \p ->
-                               logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key af Nothing $ \t -> do
+                               logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
                                        r <- tryNonAsync (Remote.retrieveKeyFile remote key af t p (RemoteVerify remote)) >>= \case
                                                Left e -> do
                                                        warning (UnquotedString (show e))
index f84f78359710da5dcb68c289d18283df52ae04e8..a87fedd2b2ae0b517d6510fa76715da334ac021f 100644 (file)
@@ -55,7 +55,7 @@ start = do
                -- so caller is responsible for doing notification
                -- and for retrying, and updating location log,
                -- and stall canceling.
-               let go p = getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key af Nothing $ \t -> do
+               let go p = getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
                        Remote.verifiedAction (Remote.retrieveKeyFile remote key af t p (RemoteVerify remote))
                in download' (Remote.uuid remote) key af Nothing noRetry go 
                        noNotification
@@ -72,7 +72,7 @@ start = do
        runner (AssistantDownloadRequest _ key (TransferAssociatedFile file)) remote =
                notifyTransfer Download file $
                        download' (Remote.uuid remote) key file Nothing stdRetry $ \p ->
-                               logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key file Nothing $ \t -> do
+                               logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
                                        r <- tryNonAsync (Remote.retrieveKeyFile remote key file t p (RemoteVerify remote)) >>= \case
                                                Left e -> do
                                                        warning (UnquotedString (show e))
index a6beb64eb328047fc2728c154a3509e7d965cf46..15a829550b5b193213bab2ea6fa440cc146237fc 100644 (file)
@@ -81,7 +81,7 @@ runLocal runst runner a = case a of
                        iv <- startVerifyKeyContentIncrementally DefaultVerify k
                        let runtransfer ti = 
                                Right <$> transfer download' k af Nothing (\p ->
-                                       logStatusAfter NoLiveUpdate k $ getViaTmp rsp DefaultVerify k af Nothing $ \tmp ->
+                                       logStatusAfter NoLiveUpdate k $ getViaTmp rsp DefaultVerify k Nothing $ \tmp ->
                                                storefile tmp o l getb iv validitycheck p ti)
                        let fallback = return $ Left $
                                ProtoFailureMessage "transfer already in progress, or unable to take transfer lock"
index 71c65715540dff76461c382b07406a2861e5f171..cda705cb0e677c5f7ca5320e6d9ed259b6d368a4 100644 (file)
@@ -682,7 +682,7 @@ copyToRemote' repo r st@(State connpool duc _ _ _) key af o meterupdate
                                let checksuccess = liftIO checkio >>= \case
                                        Just err -> giveup err
                                        Nothing -> return True
-                               logStatusAfter NoLiveUpdate key $ Annex.Content.getViaTmp rsp verify key af (Just sz) $ \dest ->
+                               logStatusAfter NoLiveUpdate key $ Annex.Content.getViaTmp rsp verify key (Just sz) $ \dest ->
                                        metered (Just (combineMeterUpdate meterupdate p)) key bwlimit $ \_ p' -> 
                                                copier object dest key p' checksuccess verify
                        )
index ea8c8e7de9f3bd584bb769abe73e84101afb799b..a5cf83e36e974aa7e66712725eaa699d544bba29 100644 (file)
@@ -25,8 +25,7 @@ upgrade = do
        olddir <- fromRepo gitAnnexDir
        keys <- getKeysPresent0 olddir
        forM_ keys $ \k ->
-               moveAnnex k (AssociatedFile Nothing)
-                       (olddir </> toOsPath (keyFile0 k))
+               moveAnnex k (olddir </> toOsPath (keyFile0 k))
 
        -- update the symlinks to the key files
        -- No longer needed here; V1.upgrade does the same thing
index b9ae3af8a827fa0a98ea6e4e5782f190361a4bf6..d0aaba73a34085bd05bbf512037509b1057ce5dc 100644 (file)
@@ -85,7 +85,7 @@ moveContent = do
                let d = parentDir f
                liftIO $ allowWrite d
                liftIO $ allowWrite f
-               _ <- moveAnnex k (AssociatedFile Nothing) f
+               _ <- moveAnnex k f
                liftIO $ removeDirectory d
 
 updateSymlinks :: Annex ()